package com.ctp.controller.manager;

import java.math.BigDecimal;
import java.util.HashMap;

import com.ctp.bean.AccountBean;
import com.ctp.bean.FormBean;
import com.ctp.bean.MarketBean;

public class TraderManager {

	private MarketBean[] markets = null;

	private AccountBean[] accts = null;

	private HashMap<String, FormBean> formPoolBySeq = null;

	private HashMap<String, FormBean> formPoolByNum = null;

	private TraderManager() {
		formPoolBySeq = new HashMap<String, FormBean>();
		formPoolByNum = new HashMap<String, FormBean>();
	}

	public MarketBean[] getMarkets() {
		return markets;
	}

	public void setMarkets(MarketBean[] markets) {
		this.markets = markets;
	}

	public AccountBean[] getAccts() {
		return accts;
	}

	public void setAccts(AccountBean[] accts) {
		this.accts = accts;
	}

	public void addFormBySeq(FormBean form) {
		formPoolBySeq.put(form.getSeqNum(), form);
	}

	public FormBean getFormBySeq(String seqNum) {
		return formPoolBySeq.get(seqNum);
	}

	public void addFormByNum(FormBean form) {
		formPoolByNum.put(form.getFormNum(), form);
	}

	public FormBean getFormByNum(String formNum) {
		return formPoolByNum.get(formNum);
	}

	public static TraderManager instance() {
		return INSTANCE;
	}

	public static int getIntPrice(double price) {
		BigDecimal decimal = new BigDecimal(price);
		return decimal.setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
	}

	public static final int VOLUME_UNIT = 1;

	public static final int PER_UNIT_TIMES = 15;

	private static final TraderManager INSTANCE = new TraderManager();

}
